#include "auto_date_time.h"

//自动生成 日期和时间
auto_date_time::auto_date_time()
{
d_num=0;
h_num=0;
m_num=0;
}

auto_date_time::~auto_date_time()
{}

void auto_date_time::init(std::string date, std::string time)
{
d_num=atoi(date.c_str());
h_num=atoi(time.substr(0,2).c_str() );
m_num=atoi(time.substr(3,2).c_str() );
}

int auto_date_time::get_next(std::string &d, std::string &t)
{
m_num++;
if(m_num > 59)
{
	m_num=0;
	h_num ++;
}
if(h_num > 23)
{
h_num = 0;
}

if(h_num == 2 && m_num > 30)
{
h_num = 9;
m_num = 0;
}
if(h_num == 11 && m_num > 30)
{
h_num = 13;
m_num = 0;
}
if(h_num == 15 && m_num == 16)
{
d_num ++;
h_num = 21;
m_num = 0;
}
d=std::to_string(d_num);
if(h_num < 10)
		{
	t = "0" + std::to_string(h_num) + ":";
		} else {
t=std::to_string(h_num)+":";
		}
if(m_num < 10)
{
t = t + "0" + std::to_string(m_num);
} else {
t = t + std::to_string(m_num);
}
return 0;
}


//获取当前
int auto_date_time::get(std::string &d, std::string &t)
{
d=std::to_string(d_num);
if(h_num < 10)
		{
	t = "0" + std::to_string(h_num) + ":";
		} else {
t=std::to_string(h_num)+":";
		}
if(m_num < 10)
{
t = t + "0" + std::to_string(m_num);
} else {
t = t + std::to_string(m_num);
}
return 0;
}



